package com.tledu.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tledu.mapper.SCMapper;
import com.tledu.mapper.SubjectMapper;
import com.tledu.pojo.SC;
import com.tledu.service.SCService;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SCServiceImpl extends ServiceImpl<SCMapper, SC> implements SCService {
    @Autowired
    private SCMapper scMapper;

    /**
     * 根据课程id找到对应的中间表中所有专辑id并且删除
     * @param course_id
     */
    @Override
    public void findSubDelete(Integer course_id){
        List<SC> scs = scMapper.find(course_id);
        for (SC sc :scs){
            Integer subject_id = sc.getSubject_id();
            scMapper.deleteBySubject_id(subject_id);
        }
    }
}
